Part Number Hot Search : 
2SD15 HA5024 ST4169A 31818 MTPH8 CSD1833D HA12174 R0605250
Product Description
Full Text Search
 

To Download HT82D22A Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ht82d22r/HT82D22A 27mhz two channel rx 8-bit mcu rev. 1.00 1 november 6, 2009 general description usb encoder built-in two 27mhz fsk receiver mcu otp body is suitable for usb interface and 27mhz wireless system. flexible total solution for applications that combine ps/2 and low-speed usb interface and 27mhz wireless system, such as mice, joysticks, and many others it consists of a holtek high performance 8-bit mcu core for control unit, built-in usb sie, 27mhz fsk receiver , 4k 15 rom and 160 bytes data ram features  usb specification compliance  conforms to usb specification v2.0  conforms to usb hid specification v1.11  supports 1 low-speed usb control endpoint and 2 interrupt endpoint  single 8-bit programmable timer counter with overflow interrupt  single 16-bit programmable timer counter with overflow interrupt  ps2 and usb modes supported  built-in two 27mhz fsk receiver  supply 27mhz fsk receiver power down function  8-level stacks  each endpoint has 8 bytes fifo  integrated usb transceiver  3.3v regulator output  integrated 27mhz fsk receiver  27mhz fsk receiver power down function  fsk receiver frequency range 26.995~27.295mhz  fsk receiver high sensitivity:  90 dbm  rf tuner, mixer, transistors, passives, coils, and saw filter functions integrated in the same device  integrated fsk receiver phase locked loop  eight user selectable frequencies  integrated fsk receiver 6kbps data rate  external 12mhz crystal  8-bit risc microcontroller, with 4k  15 eprom (000h~fffh)  160 bytes ram (20h~bfh)  6mhz internal mcu clock  two 8-bit indirect addressing registers  single usb interrupt input (vector 04h)  halt function and wake-up feature reduce power consumption  all i/o ports support wake-up function  internal power-on reset (por)  watchdog timer (wdt)  10 i/o ports  48-pin qfn package
block diagram ht82d22r/HT82D22A rev. 1.00 2 november 6, 2009        
 

     
                                                        
                       !          "  #         $                 %  &   ' ( )   )  )  &    )  &     *      +  '    , -  . /  
    0     
&   #  %  ' (  - ' 
   1 , 2 3 &   &  , 1   1  4 '     1  5 '    6 7 7   3 8  9  : ' 
3  - ' 
   ;   ,    ;       ;      ;    1  
& 1 1 1 3 ' /   5 1 ;     
&   1 3 ' /   5  ;   , -  . /  
    0     ;   , 1   ;    1   ;   1   ;   1
pin assignment pin description pin name i/o configuration option description pa0~pa5, pa6/tmr0 pa7/tmr1 i/o pull-high wake-up cmos/nmos/pmos bidirectional 8-bit input/output port. each bit can be configured as a wake-up input by rom code option. the input or output mode is controlled by pac (pa control register). pull-high resistor options: pa0~pa7 cmos/nmos/pmos output options: pa0~pa7 wake-up options: pa0~pa7 pa6 is wire-bonded with tmr0 pa7 is wire-bonded with tmr1 pb0/fsk-b_out i/o pull-high wake-up bidirectional 1-bit input/output port. software instructions deter - mine the cmos output or schmitt trigger input with pull-high re - sistor (determined by pull-high options) pb0 is wire bonded with fsk-b demodulation data output. wake-up option: pb0 pc0/fsk-a_out i/o pull-high wake-up bidirectional 1-bit input/output port. software instructions deter - mine the cmos output or schmitt trigger input with pull-high re - sistor (determined by pull-high options) pc0 is wire bonded with fsk-a demodulation data output. wake-up option: pc0 vss, gnda1a, gnda1b  negative power supply, ground res i  schmitt trigger reset input. active low. vdd,vdd-a, vdd-b vcca1a~vcca2a vcca1b~vcca2b  positive power supply v33o o  3.3v regulator output usbd+/clk i/o  usbd+ or ps2 clk i/o line usb or ps2 function is controlled by software control register usbd-/data i/o  usbd- or ps2 data i/o line usb or ps2 function is controlled by software control register ht82d22r/HT82D22A rev. 1.00 3 november 6, 2009                 
   7  (  9  :  -  <  = , 3 ,  , , , 7 , (  , 7 ( 9 : - < =  3    , 7 : 7 9 7 ( 7 7 7 , 7  7 3 , = , < , - , : , 9 7 - 7 <7 = ( 3(  ( ,( 7 ( (( 9 ( :( - ( < 6     ;   ,    ;     $      6    ,    6      6   5    ;      ;    6   6   6    , 1 $     1   ;    1   ;   , 1 6     6
+ / 1 / 1 6     1  5 '      1  4 '   6 7 7 3  -        
+  6   1 3 ' /   5 1 ;   6     ;   1   ;   1 6   5 1 6     1    :  9  (  7  ,    3  3 ' /   5  ;   6   /  6
+ +   
pin name i/o configuration option description lfa lfb i  loop filter for local oscillator (resistance 24k  and capacity 5.6nf) in parallel with capacity 560pf to ground. osci  for test pin osco  for test pin vrefa vrefb  mid rail reference voltage for fsk receiver ant_in1a ant_in1b i  antenna input 1 ant_in2a ant_in2b i  antenna input 2 xtal_ina xtal_outa xtal_inb xtal_outb i o i o  xtal_ina, xtal_inb, xtal_outa, xtal_outb are con - nected to a 12mhz crystal absolute maximum ratings supply voltage ...........................v ss  0.3v to v ss +6.0v storage temperature ............................ 50 cto125 c input voltage..............................v ss  0.3v to v dd +0.3v operating temperature...............................0  cto70 c note: these are stress ratings only. stresses exceeding the range specified under absolute maximum ratings may cause substantial damage to the device. functional operation of this device at other conditions beyond those listed in the specification is not implied and prolonged exposure to extreme conditions may affect device reliability. d.c. characteristics ta=25 c symbol parameter test conditions min. typ. max. unit v dd conditions v dd operating voltage  4.0  5.5 v i dd operating current 5v no load, f xtal =12mhz  25  ma i stb1 standby current 5v no load, system halt, usb suspend**, fsk receiver power down  1.5  ma i stb2 standby current 5v no load, system halt, input/output mode, set suspend2 [1ch].4, fsk receiver power down  1.0  ma v il1 input low voltage for i/o ports 5v  0  0.8 v v ih1 input high voltage for i/o ports 5v  2  v dd v v il2 input low voltage (res )5v  0  0.4v dd v v ih2 input high voltage (res )5v  0.9v dd  v dd v i ol1 i/o port sink current for pa1~pa7, pb0, pc0 5v v ol =0.4v 248ma i ol2 i/o port sink current for pa0 5v v ol =0.4v 7 10 13 ma i oh1 i/o port source current for pa1~pa7, pb0, pc0 5v v oh =3.4v 2 4 -8 ma i oh2 i/o port source current for pa0 5v v oh =3.4v -12 -18 -24 ma ht82d22r/HT82D22A rev. 1.00 4 november 6, 2009
symbol parameter test conditions min. typ. max. unit v dd conditions r ph1 pull-high resistance for data*  1.3 1.5 2.0 k r ph2 pull-high resistance for pa, pb, pc, pd  2.0 4.7 6.0 k r ph3 pull-high resistance for pa, pb0, pc0 5v  25 50 80 k v lvr low voltage reset 5v  2.4 2.7 3 v note: * the data pull-high must be implemented by the external 1.5k . ** include 15k  loading of usbd+, usbd- line in host terminal. a.c. characteristics ta=25 c symbol parameter test conditions min. typ. max. unit v dd conditions f sys system clock (crystal osc) 5v  6  mhz f xtal quartz xtal frequency   12  mhz xppm quartz xtal frequency tolerance  
50  ppm c xtal xtal shunt capacitance   47  pf t wdt watchdog time-out period (system clock)  without wdt prescaler 1024  t rcsys t res external reset low pulse width  1  ms t sst system start-up timer period  wake-up from halt 1024  t sys power-up, watchdog time-out from normal 1024 t wdtosc t osc crystal setup   510ms t dev 27mhz therefore signal input frequency deviation 5v  3.2  khz t wdtosc watchdog oscillator 5v  15 31 70 us ht82d22r/HT82D22A rev. 1.00 5 november 6, 2009
rf characteristics ta=25 c symbol parameter test conditions min. typ. max. unit v cc conditions f chn channel spacing 5v  50  khz f com communication spacing 5v pb3 pb2 pb1 or pd5 pd4 pc3 000 001 010 011 100 101 110 111  26.995 27.045 27.095 27.145 27.195 27.245 27.295 26.945  mhz r in input resistance 5v dc  < 100  k differential @27mhz  8  k c in input capacitance 5v differential @27mhz  5  pf a sens antenna input sensitivity 5v antenna input 50  to 8k  impedance transform 90  dbm ac rej adjacent channel rejection 5v 50khz offset, 100khz & 150khz offsets  1.5 28  db f dev frequency deviation 5v  3.2  khz dr fsk data rate 5v  6k  bit/sec v ref1 internal mid-rail reference 5v  1.6  v v ref2 internal supply voltage reference 5v  3.3  v t pu power up settling time 5v  3  ms ht82d22r/HT82D22A rev. 1.00 6 november 6, 2009
ht82d22r/HT82D22A rev. 1.00 7 november 6, 2009 functional description execution flow the external crystal must use 12mhz but the system clock for the microcontroller is derived from 6mhz inter - nal clock. the system clock is internally divided into four non- overlapping clocks. one instruction cycle consists of four system clock cycles. instruction fetching and execution are pipelined in such a way that a fetch takes an instruction cycle while de - coding and execution takes the next instruction cycle. however, the pipelining scheme causes each instruc - tion to be effectively executed in a cycle. if an instruction changes the program counter, two cycles are required to complete the instruction. program counter  pc the program counter (pc) controls the sequence in which the instructions stored in the program rom are executed and its contents specify a full range of pro - gram memory. after accessing a program memory word to fetch an in - struction code, the contents of the program counter are incremented by one. the program counter then points to the memory word containing the next instruction code. when executing a jump instruction, conditional skip ex - ecution, loading to the pcl register, performing a sub - routine call or return from subroutine, initial reset, internal interrupt, external interrupt or return from inter - rupts, the pc manipulates the program transfer by load - ing the address corresponding to each instruction. the conditional skip is activated by instructions. once the condition is met, the next instruction, fetched during the current instruction execution, is discarded and a dummy cycle replaces it to get the proper instruction. otherwise proceed with the next instruction. the lower byte of the program counter (pcl) is a read - able and writeable register (06h). moving data into the pcl performs a short jump. the destination will be within the current program rom page. when a control transfer takes place, an additional dummy cycle is required.  , 7 (  , 7 (  , 7 ( /    " &    & >  ? + @      &    & >  5  ? /    " &    & >  4  ? + @      &    & >  ? /    " &    & >  4 , ? + @      &    & >  4  ?   4   4 ,      &  *   a    , & >
 &   *  ?  execution flow mode program counter *11 *10 *9 *8 *7 *6 *5 *4 *3 *2 *1 *0 initial reset 000000000000 usb interrupt 000000000100 timer/event counter 0 overflow 000000001000 timer/event counter 1 overflow 000000001100 skip program counter+2 loading pcl *11 *10 *9 *8 @7 @6 @5 @4 @3 @2 @1 @0 jump, call branch #11 #10 #9 #8 #7 #6 #5 #4 #3 #2 #1 #0 return from subroutine s11 s10 s9 s8 s7 s6 s5 s4 s3 s2 s1 s0 program counter note: *11~*0: program counter bits s11~s0: stack register bits #11~#0: instruction code bits @7~@0: pcl bits
ht82d22r/HT82D22A rev. 1.00 8 november 6, 2009 program memory  rom the program memory is used to store the program in - structions which are to be executed. it also contains data, table, and interrupt entries, and is organized into 4096 15 bits, addressed by the program counter and ta - ble pointer. certain locations in the program memory are reserved for special usage:  location 000h this area is reserved for program initialization. after a chip reset, the program always begins execution at lo - cation 000h.  location 004h this area is reserved for the usb interrupt service program. if the usb interrupt is activated, the interrupt is enabled and the stack is not full, the program begins execution at location 004h.  location 008h this location is reserved for the timer/event counter 0 interrupt service program. if a timer results from a timer/event counter 0 overflow. and the interrupt is enables and the stack is not full, the program begins execution at location 008h.  location 00ch this location is reserved for the timer/event counter 1 interrupt service program. if a timer interrupt results from a timer/event counter 1 overflow, and the inter- rupt is enabled and the stack is not full, the program begins execution at location 00ch.  table location any location in the program memory can be used as look-up tables. there are three method to read the rom data by two table read instructions: tabrdc and tabrdl , transfer the contents of the lower-order byte to the specified data memory, and the higher-order byte to tblh (08h). the three methods are shown as follows: the instructions tabrdc [m] (the current page, one page=256words), where the table locations is defined by tblp (07h) in the current page. and the rom code option tbhp is disabled (default). the instructions tabrdc [m] , where the table lo - cations is defined by registers tblp (07h) and tbhp (01fh). and the rom code option tbhp is enabled. the instructions tabrdl [m] , where the table lo - cations is defined by registers tblp (07h) in the last page (0f00h~0fffh). only the destination of the lower-order byte in the ta - ble is well-defined, the other bits of the table word are transferred to the lower portion of tblh , and the re - maining 1-bit words are read as 0 . the table higher-order byte register (tblh) is read only. the ta - ble pointer (tblp, tbhp) is a read/write register (07h, 1fh), which indicates the table location. before ac- cessing the table, the location must be placed in the tblp and tbhp (if the otp option tbhp is disabled, the value in tbhp has no effect). the tblh is read only and cannot be restored. if the main routine and the isr (interrupt service routine) both employ the table read instruction, the contents of the tblh in the main routine are likely to be changed by the table read instruction used in the isr. errors can occur. in other words, using the table read instruction in the main rou- tine and the isr simultaneously should be avoided. however, if the table read instruction has to be applied in both the main routine and the isr, the interrupt should be disabled prior to the table read instruction. it will not be enabled until the tblh has been backed up. all table related instructions require two cycles to complete the operation. these areas may function as normal program memory depending on the require - ments. once tbhp is enabled, the instruction tabrdc [m] reads the rom data as defined by tblp and tbhp value. otherwise, the rom code option tbhp is dis - abled, the instruction tabrdc [m] reads the rom data as defined by tblp and the current program counter bits. / / /  / /               a 5   &  b *  & > , 9 : & )   ! ?   a 5   &  b *  & > , 9 : & )   ! ?     c &  &      & #    & 3 &   & / 3 3   3 3   0    &       *  .      &         1 &          &   b        3 3 ( 3 3 3     ' + 0    &        & 3          &   b        &     ' + 0    &        &           &   b        &  9 & 1   3 3 < program memory structure instruction table location *11 *10 *9 *8 *7 *6 *5 *4 *3 *2 *1 *0 tabrdc [m] p11 p10 p9 p8 @7 @6 @5 @4 @3 @2 @1 @0 tabrdl [m] 1111@7@6@5@4@3@2@1@0 note: *11~*0: table location bits @7~@0: tblp bits p11~p8: current program counter bits when tbhp is disabled tbhp register bit3~bit0 when tbhp is enabled
ht82d22r/HT82D22A rev. 1.00 9 november 6, 2009 stack register  stack this is a special part of the memory which is used to save the contents of the program counter only. the stack is organized into 8 levels and is neither part of the data nor part of the program space, and is neither read - able nor writeable. the activated level is indexed by the stack pointer (sp) and is neither readable nor writeable. at a subroutine call or interrupt acknowledge signal, the contents of the program counter are pushed onto the stack. at the end of a subroutine or an interrupt routine, signaled by a return instruction (ret or reti), the pro - gram counter is restored to its previous value from the stack. after a chip reset, the sp will point to the top of the stack. if the stack is full and a non-masked interrupt takes place, the interrupt request flag will be recorded but the acknowledge signal will be inhibited. when the stack pointer is decremented (by ret or reti), the interrupt will be serviced. this feature prevents stack overflow al - lowing the programmer to use the structure more easily. in a similar case, if the stack is full and a call is sub - sequently executed, stack overflow occurs and the first entry will be lost (only the most recent 4 return ad - dresses are stored). data memory  ram for bank 0 the special function registers include the indirect ad- dressing registers (iar0;00h, iar1;02h), bank register (bp, 04h), timer/event counter 0 (tmr0;0dh), timer/event counter 0 control register (tmr0c;0eh), timer/event counter 1 higher order byte register (tmr1h;0fh), timer/event counter 1 lower order byte register (tmr1l;10h), timer/event counter 1 control register (tmr1c;11h), program counter lower-order byte register (pcl;06h), memory pointer registers (mp0;01h, mp1;03h), accumulator (acc;05h), table pointer (tblp;07h, tbhp;1fh), table higher-order byte register (tblh;08h), status register (status;0ah), in - terrupt control register (intc;0bh), watchdog timer option setting register (wdts;09h), i/o registers (pa;12h, pb;14h, pc;16h), i/o control registers (pac;13h, pbc;15h, pcc;17h). usb/ps2 status and control register (usc;1ah), usb endpoint interrupt status register (usr;1bh), system clock con - trol register (scc;1ch). the remaining space before the 20h is reserved for future expansion usage and reading these locations will get 00h . the general pur - pose data memory, addressed from 20h to bfh, is used for data and control information under instruction com - mands. all of the data memory areas can handle arithmetic, logic, increment, decrement and rotate operations di - rectly. except for some dedicated bits, each bit in the data memory can be set and reset by set [m].i and clr [m].i . they are also indirectly accessible through memory pointer registers (mp0 or mp1). $      * &          &       >  : 3 & 1    ? 1 /  
3  3  
   1     1 1 )          
3 
3  
 
 
     1 1            
   1 c &    ! &
  ! &  & d 3 3 d    
 3 3 3  3 , 3 7 3 ( 3 9 3 : 3 - 3 < 3 = 3  3 1 3  3  3 + 3 /  3    ,  7  (  9  :  -  <  =    1      +  / , 3 bank0 ran mapping
ht82d22r/HT82D22A rev. 1.00 10 november 6, 2009 data memory  ram for bank 1 the special function registers used in the usb interface are located in ram bank1. in order to access bank1 register, only the indirect addressing pointer mp1 can be used and the bank register bp should be set to 1. the ram bank 1 mapping is as shown. address 00~1fh in ram bank0 and bank1 are located in the same registers indirect addressing register locations 00h and 02h are indirect addressing regis- ters (iar0, iar1) that are not physically implemented. any read/write operation on [00h] ([02h]) will access the data memory pointed to by mp0 (mp1). reading loca - tion 00h (02h) indirectly will return the result 00h. writ - ing indirectly results in no operation. the indirect addressing pointer (mp0) always points to bank0 ram addresses no matter the value of bank register (bp). the indirect addressing pointer (mp1) can access bank0 or bank1 ram data according to the value of bp which is set to 0 or 1 respectively. the memory pointer registers (mp0 and mp1) are 8-bit registers. accumulator the accumulator is closely related to alu operations. it is also mapped to location 05h of the data memory and can carry out immediate data operations. the data movement between two data memory locations must pass through the accumulator. arithmetic and logic unit  alu this circuit performs 8-bit arithmetic and logic opera - tions. the alu provides the following functions:  arithmetic operations (add, adc, sub, sbc, daa)  logic operations (and, or, xor, cpl)  rotation (rl, rr, rlc, rrc)  increment and decrement (inc, dec)  branch decision (sz, snz, siz, sdz ....) the alu not only saves the results of a data operation but also changes the status register. status register  status this 8-bit register (0ah) contains the zero flag (z), carry flag (c), auxiliary carry flag (ac), overflow flag (ov), power down flag (pdf), and watchdog time-out flag (to). it also records the status information and controls the operation sequence. with the exception of the to and pdf flags, bits in the status register can be altered by instructions like most c &    ! &
  ! &  & d 3 3 d (  ( , ( 7 ( ( ( 9 ( : ( - ( < ( = (  ( 1 (   + ; 
 )
   +   +      +  !   ; +  /  /  3 /  /   /  /  ,   !  #    ! e &     0  ! #   & #      &  @          
 / / bank 1 ram mapping bit no. label function 0c c is set if an operation results in a carry during an addition operation or if a borrow does not take place during a subtraction operation; otherwise c is cleared. c is also affected by a rotate through carry instruction. 1ac ac is set if an operation results in a carry out of the low nibbles in addition or no borrow from the high nibble into the low nibble in subtraction; otherwise ac is cleared. 2 z z is set if the result of an arithmetic or logic operation is zero; otherwise z is cleared. 3ov ov is set if an operation results in a carry into the highest-order bit but not a carry out of the highest-order bit, or vice versa; otherwise ov is cleared. 4 pdf pdf is cleared by a system power-up or executing the clr wdt instruction. pdf is set by executing the halt instruction. 5to to is cleared by a system power-up or executing the clr wdt or halt instruction. to is set by a wdt time-out. 6, 7  unused bit, read as 0 status (0ah) register
ht82d22r/HT82D22A rev. 1.00 11 november 6, 2009 other registers. any data written into the status register will not change the to or pdf flag. in addition, opera - tions related to the status register may give different re - sults from those intended. the to flag can be affected only by a system power-up, a wdt time-out or executing the clr wdt or halt instruction. the pdf flag can be affected only by exe - cuting the halt or clr wdt instruction or during a system power-up. the z, ov, ac and c flags generally reflect the status of the latest operations. in addition, upon entering the interrupt sequence or exe - cuting a subroutine call, the status register will not be automatically pushed onto the stack. if the contents of the status are important and if the subroutine can cor - rupt the status register, precautions must be taken to save it properly. interrupt the device provides an external interrupt and internal timer/event counter interrupts. the interrupt control register (intc;0bh) contains the interrupt control bits to set the enable/disable and the interrupt request flags. once an interrupt subroutine is serviced, all the other in - terrupts will be blocked (by clearing the emi bit). this scheme may prevent any further interrupt nesting. other interrupt requests may occur during this interval but only the interrupt request flag is recorded. if a certain inter- rupt requires servicing within the service routine, the emi bit and the corresponding bit of the intc may be set to allow interrupt nesting. if the stack is full, the inter- rupt request will not be acknowledged, even if the re- lated interrupt is enabled, until the sp is decremented. if immediate service is desired, the stack must be pre - vented from becoming full. all these kinds of interrupts have a wake-up capability. as an interrupt is serviced, a control transfer occurs by pushing the program counter onto the stack, followed by a branch to a subroutine at a specified location in the program memory. only the program counter is pushed onto the stack. if the contents of the register or status register (status) are altered by the interrupt service program which corrupts the desired control sequence, the contents should be saved in advance. the usb interrupts are triggered by the following usb events and the related interrupt request flag (usbf; bit 4 of the intc) will be set.  access of the corresponding usb fifo from pc  the usb suspend signal from pc  the usb resume signal from pc  usb reset signal when the interrupt is enabled, the stack is not full and the external interrupt is active, a subroutine call to loca - tion 04h will occur. the interrupt request flag (usbf) and emi bits will be cleared to disable other interrupts. when the pc host access the fifo, the corresponding request bit of the usr is set, and a usb interrupt is trig - gered. so user can easily decide which fifo is ac - cessed. when the interrupt has been served, the corresponding bit should be cleared by firmware. when the device receives a usb suspend signal from the host pc, the suspend line (bit0 of the usc) is set and a usb interrupt is also triggered. when the device receives a resume signal from the host pc, the resume line (bit3 of the usc) are set and a usb interrupt is triggered. whenever a usb reset signal is detected, the usb in- terrupt is triggered and urst bit of the usc register is set. when the interrupt has been served, the bit should be cleared by firmware. the internal timer/event counter 0 interrupt is initial- ized by setting the timer/event counter 0 interrupt re- quest flag (t0f; bit 5 of intc), caused by a timer 0 overflow. when the interrupt is enabled, the stack is not full and the t0f bit is set, a subroutine call to location 08h will occur. the related interrupt request flag (t0f) will be reset and the emi bit cleared to disable further in - terrupts. the internal timer/even counter 1 interrupt is initialized bit no. label function 0 emi controls the master (global) interrupt (1=enable; 0=disable) 1 eui controls the usb interrupt (1=enable; 0= disable) 2 et0i controls the timer/event counter0 interrupt (1=enable; 0=disable) 3 et1i controls the timer/event counter1 interrupt (1=enable; 0=disable) 4 usbf usb interrupt request flag (1=active; 0=inactive) 5 t0f internal timer/event counter0 request flag (1:active; 0:inactive) 6 t1f internal timer/event counter request flag (1:active; 0:inactive) 7  unused bit, read as 0 intc (0bh) register
ht82d22r/HT82D22A rev. 1.00 12 november 6, 2009 by setting the timer/event counter 1 interrupt request flag (t1f; bit 6 of intc), caused by a timer 1 overflow. when the interrupt is enabled, the stack is not full and the t1f is set, a subroutine call to location 0ch will oc - cur. the related interrupt request flag (t1f) will be reset and the emi bit cleared to disable further interrupts. during the execution of an interrupt subroutine, other in - terrupt acknowledge signals are held until the reti in - struction is executed or the emi bit and the related interrupt control bit are set to 1 (if the stack is not full). to return from the interrupt subroutine, ret or reti may be invoked. reti will set the emi bit to enable an interrupt service, but ret will not. interrupts, occurring in the interval between the rising edges of two consecutive t2 pulses, will be serviced on the latter of the two t2 pulses, if the corresponding inter - rupts are enabled. in the case of simultaneous requests the following table shows the priority that is applied. these can be masked by resetting the emi bit. interrupt source priority vector usb interrupt 1 04h timer/event counter 0 overflow 2 08h timer/event counter 1 overflow 3 0ch the timer/event counter 0/1 interrupt request flag (t0f/t1f), usb interrupt request flag (usbf), enable timer/event counter 0/1 interrupt bit (et0i/et1i), enable usb interrupt bit (eui) and enable master interrupt bit (emi) constitute an interrupt control register (intc) which is located at 0bh in the data memory. emi, eui, eti are used to control the enabling/disabling of interrupts. these bits prevent the requested interrupt from being serviced. once the interrupt request flags (tf, usbf) are set, they will remain in the intc register until the interrupts are ser - viced or cleared by a software instruction. it is recommended that a program does not use the call subroutine within the interrupt subroutine. inter - rupts often occur in an unpredictable manner or need to be serviced immediately in some applications. if only one stack is left and enabling the interrupt is not well con - trolled, the original control sequence will be damaged once the call operates in the interrupt subroutine. oscillator configuration there is an oscillator circuit in the microcontroller. this oscillator is designed for system clocks. the halt mode stops the system oscillator and ignores an exter - nal signal to conserve power. a crystal across xtal_ina or xtal_inb and xtal_outa or xtal_outb is needed to provide the feedback and phase shift required for the oscillator. no other external components are required. in stead of a crystal, a resonator can also be connected between xtal_ina or xtal_inb and xtal_outa or xtal_outb to get a frequency reference, but two ex - ternal capacitors in xtal_ina or xtal_inb and xtal_outa or xtal_outb are required. the external crystal must use 12mhz but it operate in 6mhz system clock. the usb sie function also operate in 6mhz. both of axtal_ina or xtal_inbnd xtal_outa or xtal_outb pin must be connect a 47pf capacitor to ground. the wdt oscillator is a free running on-chip rc oscilla - tor, and no external components are required. even if the system enters the power down mode, the system clock is stopped, but the wdt oscillator still works within a period of approximately 31 s. the wdt oscillator can be disabled by rom code option to conserve power. watchdog timer  wdt the wdt clock source is implemented by a dedicated rc oscillator (wdt oscillator), or instruction clock (sys- tem clock divided by 4), determine by rom code option. this timer is designed to prevent a software malfunction or sequence from jumping to an unknown location with unpredictable results. the watchdog timer can be dis- abled by rom code option. if the watchdog timer is dis- abled, all the executions related to the wdt result in no operation. once the internal wdt oscillator (rc oscillator with a period of 31 s/5v normally) is selected, it is first divided by 256 (8-stage) to get the nominal time-out period of 8ms/5v. this time-out period may vary with tempera - tures, vdd and process variations. by invoking the wdt prescaler, longer time-out periods can be realized. writing data to ws2, ws1, ws0 (bits 2, 1, 0 of the wdts) can give different time-out periods. if ws2, ws1, and ws0 are all equal to 1, the division ratio is up to 1:128, and the maximum time-out period is 1s/5v. if the wdt oscillator is disabled, the wdt clock may still come from the instruction clock and operates in the same manner except that in the halt state the wdt may stop counting and lose its protecting purpose. in this situation the logic can only be restarted by external logic. the high nibble and bit 3 of the wdts are re - served for user defined flags, which can only be set to 10000 (wdts.7~wdts.3).       
            ;    &   ;   1 ( -  / ( -  /   ;    &   ;   1 system oscillator
ht82d22r/HT82D22A rev. 1.00 13 november 6, 2009 if the device operates in a noisy environment, using the on-chip 32khz rc oscillator (wdt osc) is strongly rec - ommended, since the halt will stop the system clock. ws2 ws1 ws0 division ratio 000 1:1 001 1:2 010 1:4 011 1:8 1 0 0 1:16 1 0 1 1:32 1 1 0 1:64 1 1 1 1:128 wdts (09h) register the wdt overflow under normal operation will initialize a chip reset and set the status bit to . but in the halt mode, the overflow will initialize a warm reset and only the program counter and sp are reset to zero. to clear the contents of the wdt (including the wdt prescaler), three methods are adopted; external reset (a low level to res ), software instruction and a halt in- struction. the software instruction include clr wdt and the other set  clr wdt1 and clr wdt2 .of these two types of instruction, only one can be active de - pending on the rom code option  clr wdt times se - lection option .ifthe clr wdt is selected (i.e. clrwdt times is equal to one), any execution of the clr wdt instruction will clear the wdt. in the case that clr wdt and clr wdt are chosen (i.e. clrwdt times is equal to two), these two instructions must be executed to clear the wdt; otherwise, the wdt may reset the chip as a result of time-out. power down operation  halt the halt mode is initialized by the halt instruction and results in the following:  the system oscillator will be turned off but the wdt oscillator remains running (if the wdt oscillator is se - lected).  the contents of the on-chip ram and registers remain unchanged.  the wdt and wdt prescaler will be cleared and re - counted again (if the wdt clock is from the wdt os - cillator).  all of the i/o ports remain in their original status.  the pdf flag is set and the to flag is cleared. the system can leave the halt mode by means of an external reset, an interrupt, an external falling edge sig - nal on port a, pb0, pc0 or a wdt overflow. an external reset causes a device initialization and the wdt over - flow performs a warm reset . after the to and pdf flags are examined, the cause for chip reset can be de - termined. the pdf flag is cleared by a system power-up or executing the clr wdt instruction and is set when executing the halt instruction. the to flag is set if the wdt time-out occurs, and causes a wake-up that only resets the program counter and sp; the others re- main in their original status. the port a, pb0, pc0 wake-up and interrupt methods can be considered as a continuation of normal execu- tion. each bit in port a, pb0, pc0 can be independently selected to wake-up the device by mask option, pb0, pc0 can also be selected to wake up the device by op- tion. awakening from an i/o port stimulus, the program will resume execution of the next instruction. if it awak - ens from an interrupt, two sequence may occur. if the re - lated interrupt is disabled or the interrupt is enabled but the stack is full, the program will resume execution at the next instruction. if the interrupt is enabled and the stack is not full, the regular interrupt response takes place. if an interrupt request flag is set to 1 before entering the halt mode, the wake-up function of the related inter - rupt will be disabled. once a wake-up event occurs, it takes 1024 t sys (system clock period) to resume normal operation. in other words, a dummy period will be in - serted after a wake-up. if the wake-up results from an in - terrupt acknowledge signal, the actual interrupt subroutine execution will be delayed by one or more cy - cles. if the wake-up results in the next instruction execu - tion, this will be executed immediately after the dummy period is finished. to minimize power consumption, all the i/o pins should be carefully managed before entering the halt status.      &  *   a ' ( < 5 b   &        )  &     *   - 5 b   &        < 5   5  &    )  &    5    )  3 8 )  ,
    !          *    )     watchdog timer
ht82d22r/HT82D22A rev. 1.00 14 november 6, 2009 reset there are four ways in which a reset can occur:  res reset during normal operation  res reset during halt  wdt time-out reset during normal operation  usb reset the wdt time-out during halt is different from other chip reset conditions, since it can perform a warm re - set that resets only the program counter and stack pointer, leaving the other circuits in their original state. some registers remain unchanged during other reset conditions. most registers are reset to the initial condi - tion when the reset conditions are met. by examining the pdf and to flags, the program can distinguish be - tween different chip resets . to pdf reset conditions 0 0 res reset during power-up 0 0 res reset during normal operation 0 0 res wake-up halt 1 u wdt time-out during normal operation 1 1 wdt wake-up halt note: u stands for unchanged to guarantee that the system oscillator is started and stabilized, the sst (system start-up timer) provides an extra delay of 1024 system clock pulses when the sys- tem resets (power-up, wdt time-out or res reset) or the system awakes from the halt state. when a system reset occurs, the sst delay is added during the reset period. any wake-up from halt will en- able the sst delay. the functional unit chip reset status are shown below. program counter 000h interrupt disable prescaler clear wdt clear. after master reset, wdt begins counting timer/event counter off input/output ports input mode stack pointer points to the top of the stack 6  
+  reset circuit )    &
   )     * !
  
+       &
      3 5 b   &
   *             reset configuration   
+  6     &    5     "   & &
   reset timing chart
ht82d22r/HT82D22A rev. 1.00 15 november 6, 2009 the registers status are summarized in the following table. register reset (power on) wdt time-out (normal operation) res reset (normal operation) res reset (halt) wdt time-out (halt)* usb-reset (normal) usb-reset (halt) tmr0 xxxx xxxx 0000 0000 0000 0000 0000 0000 uuuu uuuu uuuu uuuu uuuu uuuu tmr0c 00-0 1000 00-0 1000 00-0 1000 00-0 1000 uu-u uuuu 00-0 1000 00-0 1000 tmr1h xxxx xxxx 0000 0000 0000 0000 0000 0000 uuuu uuuu uuuu uuuu uuuu uuuu tmr1l xxxx xxxx 0000 0000 0000 0000 0000 0000 uuuu uuuu uuuu uuuu uuuu uuuu tmr1c 00-0 1--- 00-0 1--- 00-0 1--- 00-0 1--- uu-u u--- 00-0 1--- 00-0 1--- program counter 000h 000h 000h 000h 000h 000h 000h mp0 xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu mp1 xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu acc xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu tblp xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu tblh -xxx xxxx -uuu uuuu -uuu uuuu -uuu uuuu -uuu uuuu -uuu uuuu -uuu uuuu tbhp ---- xxxx ---- uuuu ---- uuuu ---- uuuu ---- uuuu ---- uuuu ---- uuuu status --00 xxxx --1u uuuu --00 uuuu --00 uuuu --11 uuuu --uu uuuu --01 uuuu intc -000 0000 -000 0000 -000 0000 -000 0000 -uuu uuuu -000 0000 -000 0000 wdts 1000 0111 1000 0111 1000 0111 1000 0111 uuuu uuuu 1000 0111 1000 0111 pa 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111 pac 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111 pb ---- ---1 ---- ---1 ---- ---1 ---- ---1 ---- ---u ---- ---1 ---- ---1 pbc ---- ---1 ---- ---1 ---- ---1 ---- ---1 ---- ---u ---- ---1 ---- ---1 pc ---- ---1 ---- ---1 ---- ---1 ---- ---1 ---- ---u ---- ---1 ---- ---1 pcc ---- ---1 ---- ---1 ---- ---1 ---- ---1 ---- ---u ---- ---1 ---- ---1 usc 11xx 0000 uuxx uuuu 11xx 0000 11xx 0000 uuxx uuuu 1100 0u00 1100 0u00 usr 0000 0000 uuuu uuuu 0000 0000 0000 0000 uuuu uuuu u0uu 0000 u0uu 0000 scc 0000 0000 uuuu uuuu 0000 0000 0000 0000 uuuu uuuu uu00 u000 uu00 u000 pipe_ctl 0000 0010 0000 uuuu 0000 0010 0000 0010 0000 uuuu 0000 0010 0000 0010 awr 0000 0000 uuuu uuuu 0000 0000 0000 0000 uuuu uuuu 0000 0000 0000 0000 stall 0000 0010 0000 uuuu 0000 0010 0000 0010 0000 uuuu 0000 0010 0000 0010 pipe 0000 0000 xxxx xxxx 0000 0000 0000 0000 xxxx xxxx 0000 0000 0000 0000 sies 0xxx xx00 uxxx xxuu 0xxx xx00 0xxx xx00 uxxx xxuu 0xxx xx00 0xxx xx00 misc 0x00 0000 uxuu uuuu 0x00 0000 0x00 0000 uxuu uuuu 0x00 0000 0x00 0000 fifo0 xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu 0000 0000 0000 0000 fifo1 xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu 0000 0000 0000 0000 fifo2 xxxx uuuu uuuu uuuu uuuu 0000 0000 0000 0000 note: * stands for warm reset u stands for unchanged x stands for unknown
ht82d22r/HT82D22A rev. 1.00 16 november 6, 2009 bit no. label function 0~2, 5  unused bit, read as 0 3 t0e to define the tmr0 active edge of timer/event counter 0 0=active on low to high (default); 1=active on high to low 4 t0on to enable/disable timer 0 counting 0=disable (default); 1=enable 6 7 t0m0 t0m1 to defines the operating mode 01=event count mode (external clock) 10=timer mode (internal clock) 11=pulse width measurement mode 00=unused (default) tmr0c (0eh) register timer/event counter two timer/event counters (tmr0, tmr1) are imple - mented in the microcontroller. the timer/event counter 0 contains an 8-bit programmable count-up counter and the clock may comes from an external source or from f sys /4. the timer/event counter 1 contains an 16-bit program - mable count-up counter and the clock may come from an external source or from the system clock divided by 4 bit no. label function 0~2, 5  unused bit, read as 0 3 t1e to define the tmr1 active edge of timer/event counter 1 0=active on low to high (default); 1=active on high to low) 4 t1on to enable/disable timer 1 counting 0=disable (default); 1=enable 6 7 t1m0 t1m1 to defines the operating mode 01=event count mode (external clock) 10=timer mode (internal clock) 11=pulse width measurement mode 00=unused (default) tmr1c (11h) register 3   3  3 3 + 3   3  3 3    *  & )  !  "             !  &       *     ' + 0    &        & 3   *   ! &
          ' + 0           & 3     & 1 
 *   !  0   # *  f   &          #  %  ' ( timer/event counter 0      3 
  +      3     *  & )  !  "             !  &       *  : & 1       ' + 0    &          *   ! &
          & 1 
 *   !  0   # *  f   &          #  %  ' (  : & 1       ' + 0    &        > 
 ' 
 ?  f & 1    1  # #   timer/event counter 1
ht82d22r/HT82D22A rev. 1.00 17 november 6, 2009 using the internal clock source, there is reference time-base for timer/event counter 0 and timer/event counter 1. the internal clock source is coming from f sys /4. the external clock input allows the user to count exter - nal events, measure time intervals or pulse widths. there are 2 registers related to the timer/event counter 0; tmr0 ([0dh]), tmr0c ([0eh]). two physical regis - ters are mapped to tmr0 location; writing tmr0 makes the starting value be placed in the timer/event counter 0 preload register and reading tmr0 gets the contents of the timer/event counter 0. the tmr0c is a timer/event counter control register, which defines some options. there are 3 registers related to timer/event counter 1; tmr1h (0fh), tmr1l (10h), tmr1c (11h). writing tmr1l will only put the written data to an internal lower-order byte buffer (8 bits) and writing tmr1h will transfer the specified data and the contents of the lower-order byte buffer to tmr1h and tmr1l preload registers, respectively. the timer/event counter 1 preload register is changed by each writing tmr1h op - erations. reading tmr1h will latch the contents of tmr1h and tmr1l counters to the destination and the lower-order byte buffer, respectively. reading the tmr1l will read the contents of the lower-order byte buffer. the tmr1c is the timer/event counter 1 control register, which de- fines the operating mode, counting enable or disable and active edge. the t0m0/t0m1, t1m0/t1m1 bits define the operating mode. the event count mode is used to count external events, which means the clock source comes from an external (tmr0/tmr1) pin. the timer mode functions as a normal timer with the clock source coming from the fsys/4 (timer0/timer1). the pulse width measurement mode can be used to count the high or low level duration of the external signal (tmr0/tmr1). the counting is based on the fsys/4 (timer0/timer1). in the event count or timer mode, once the timer/event counter 0/1 starts counting, it will count from the current contents in the timer/event counter 0/1 to ffh or ffffh. once overflow occurs, the counter is reloaded from the timer/event counter 0/1 preload register and generates the interrupt request flag (t0f/t1f; bit 5/6 of intc) at the same time. in the pulse width measurement mode with the t0on/t1on and te bits equal to one, once the tmr0/tmr1 has received a transient from low to high (or high to low if the t0e/t1e bits is _0_) it will start counting until the tmr0/tmr1 returns to the original level and resets the t0on/t1on. the measured result will remain in the timer/event counter 0/1 even if the activated transient occurs again. in other words, only one cycle measurement can be done. until setting the t0on/t1on, the cycle measurement will function again as long as it receives further transient pulse. note that, in this operating mode, the timer/event counter 0/1 starts counting not according to the logic level but ac - cording to the transient edges. in the case of counter overflows, the counter 0/1 is reloaded from the timer/event counter 0/1 preload register and issues the interrupt request just like the other two modes. to en - able the counting operation, the timer on bit (t0on/t1on; bit 4 of tmr0c/tmr1c) should be set to1. in the pulse width measurement mode, the t0on/t1on will be cleared automatically after the mea - surement cycle is completed. but in the other two modes the t0on/t1on can only be reset by instruc - tions. the overflow of the timer/event counter 0/1 is one of the wake-up sources. no matter what the opera- tion mode is, writin ga0to et0i/et1i can disable the corresponding interrupt services. in the case of timer/event counter 0/1 off condition, writing data to the timer/event counter 0/1 preload reg- ister will also reload that data to the timer/event coun- ter 0/1. but if the timer/event counter 0/1 is turned on, data written to it will only be kept in the timer/event counter 0/1 preload register. the timer/event counter 0/1 will still operate until overflow occurs (a timer/event counter 0/1 reloading will occur at the same time). when the timer/event counter 0/1 (reading tmr0/tmr1) is read, the clock will be blocked to avoid errors. as clock blocking may results in a counting error, this must be taken into consideration by the program - mer.
ht82d22r/HT82D22A rev. 1.00 18 november 6, 2009 input/output ports there are 10 bidirectional input/output lines in the microcontroller, labeled from pa, pb0, pc0 which are mapped to the data memory of [12h] [14h] [16h] re - spectively. all of these i/o ports can be used for input and output operations. for input operation, these ports are non-latching, that is, the inputs must be ready at the t2 rising edge of instruction mov a,[m] (m=12h, 14h, 16h). for output operation, all the data is latched and re - mains unchanged until the output latch is rewritten. each i/o line has its own control register (pac) (pbc) (pcc) to control the input/output configuration. with this control register, cmos/nmos/pmos output or schmitt trigger input with or without pull-high/low resistor struc - tures can be reconfigured dynamically under software control. to function as an input, the corresponding latch of the control register must write a 1 . the input source also depends on the control register. if the control regis - ter bit is 1 , the input will read the pad state. if the con - trol register bit is 0 , the contents of the latches will move to the internal bus. the latter is possible in the read-modify-write instruction. for output function, cmos/nmos/pmos configurations can be selected. these control registers are mapped to locations 13h, 15h and 17h. after a chip reset, these input/output lines remain at high levels or in a floating state (depending on the pull-high/low options). each bit of these input/output latches can be set or cleared by set [m].i and clr [m].i (m=12h, 14h, 16h) instructions. some instructions first input data and then follow the output operations. for example, set [m].i , clr [m].i , cpl [m] , cpla [m] read the entire port states into the cpu, execute the defined operations (bit-operation), and then write the results back to the latches or the accumulator. each line of port i/o has the capability of waking-up the device. there are pull-high/low options available for i/o lines. once the pull-high/low option of an i/o line is selected, the i/o line have pull-high/low resistor. otherwise, the pull-high/low resistor is absent. it should be noted that a non-pull-high/low i/o line operating in input mode will cause a floating state. it is recommended that unused or not bonded out i/o lines should be set as output pins by software instruction to avoid consuming power under input floating state. pc0/pb0 is wire-bonded with fsk-a/fsk-b demodula - tion data output. if want read fsk-a/fsk-b demodula - tion data pc0/pb0 must set to input mode. 6    '  &       )  a  5   &       & #   &    &  '  &   
  ! &     &
       g     g          * & 1       & 1  )     &       * &
       "   &
  
  ! &       * &
      )     &     &
          & 1   )  a  5   & #   &    &  '  &      : ' 
3  - ' 
    &          #          g g input/output ports
ht82d22r/HT82D22A rev. 1.00 19 november 6, 2009 low voltage reset  lvr the microcontroller contains a low voltage reset circuit in order to monitor the supply voltage of the device. if the supply voltage of the device drops to within the range of 0.9v~v lvr such as might occur when changing the bat - tery, the lvr will automatically reset the device inter - nally. the lvr includes the following specifications:  for a valid lvr signal, a low voltage (0.9v~v lvr ) must exist for more than 1ms. if the low voltage state does not exceed 1ms, the lvr will ignore it and will not per - form a reset function.  the lvr uses the or function with the external res signal to perform a chip reset. the relationship between v dd and v lvr is shown below. note: v opr is the voltage range for proper chip opera- tion at 6mhz or 12mhz system clock. suspend wake-up and remote wake-up if there is no signal on the usb bus for over 3ms, the de - vices will go into suspend mode. the suspend line (bit 0 of the usc) will be set to 1 and a usb interrupt is trig - gered to indicate that the devices should jump to the suspend state, the firmware should disable the usb clock by clearing the usbcken (bit3 of the scc) to 0 . user can further decrease the suspend current by set - ting the susp2 (bit4 of the scc). if in usb mode set this bit lvr opt must disable when the resume signal is sent out by the host, the de - vices will wake up the mcu by usb interrupt and the resume line (bit 3 of the usc) is set. in order to make the device function properly, the firmware must set the usbcken (bit 3 of the scc) to 1 and clear the susp2 (bit4 of the scc). since the resume signal will be cleared before the idle signal is sent out by the host, the suspend line (bit 0 of the usc) will be set to 0 .so when the mcu is detecting the suspend line (bit0 of usc), the resume line should be remembered and taken into consideration. after finishing the resume signal, the suspend line will go inactive and a usb interrupt is triggered. the follow - ing is the timing diagram. 6   9 2 9 6 6 6
3 2 = 6 3 6
   &      *
   h  h ,      * &         
   6
&       & 6  *     low voltage reset note: *1: to make sure that the system oscillator has stabilized, the sst provides an extra delay of 1024 system clock pulses before entering the normal operation. *2: a low voltage has to exist for more than 1ms, after that 1ms delay, the device enters a reset mode. 9 2 9 6 3 2 = 6 6   6 
6 6
9 2 9 6 , 2 - 6 , 2 ( 6
ht82d22r/HT82D22A rev. 1.00 20 november 6, 2009 the device with remote wake up function can wake up the usb host by sending a wake-up pulse through rmwk (bit 1 of the usc). once the usb host receives a wake-up signal from the device, it will send a resume signal to the device. the timing is as follows: to configure the device as ps2 device the device can be configured as a usb interface or ps2 interface device, by configuring the sps2 (bit 4 of usr) and susb (bit 5 of the usr). if sps2=1, and susb=0, the device is configured as a ps2 interface, pin usbd- is configured as a ps2 data pin and usbd+ is config - ured as a ps2 clk pin. user can easily read or write to the ps2 data or ps2 clk pin by accessing the corre - sponding bit ps2dai (bit 4 of the usc), ps2cki (bit 5 of the usc), ps2dao (bit 6 of the usc) and s2cko (bit 7 of the usc) respectively. user should make sure that in order to read the data properly, the corresponding output bit must be set to 1 . for example, if it is desired to read the ps2 data by reading ps2dai, the ps2dao should set to 1 . other - wise it is always read as 0 . if sps2=0, and susb=1, the device is configured as a usb interface. both the usbd- and usbd+ is driven by the sie of the device. user can only write or read the usb data through the corresponding fifo. both sps2 and susb default is 0 . usb interface there are ten registers, including pipe_ctrl (41h in bank 1), awr (address + remote wake-up 42h in bank 1), stall (43h in bank 1), pipe (44h in bank 1), sies (45h in bank 1), misc (46h in bank 1), endpt_en (47h in bank 1), fifo0 (48h in bank 1), fifo1 (49h in bank 1), and fifo2 (4ah in bank 1) used for the usb function. awr register contains current address and a remote wake up function control bit. the initial value of awr is 00h . the address value extracted from the usb command is not to be loaded into this register until the setup stage is completed. bit no. label r/w function 0 wken w remote wake-up enable/disable 7~1 ad6~ad0 w usb device address awr (42h) register stall and pipe, pipe_ctrl, endpt_en registers pipe register represents whether the endpoint corresponding is accessed by host or not. after act_en signal being sent out, mcu can check which endpoint had been accessed. this register is set only after the time when host access the corresponding endpoint. stall register shows whether the endpoint corresponding works or not. as soon as the endpoint work improperly, the bit corresponding must be set. pipe_ctrl register is used for configuring in (bit=1) or out (bit=0)pipe. the default is define in pipe. where bit0 (data0) of the pipe_ctrl register is used to setting the data toggle of any endpoint (except endpoint0) using data toggles to the value data0. once the user want the any endpoint (except endpoint0) using data toggles to the value data0. the user can output a low pulse to this bit. the low pulse period must at least 10 instruction cycle. endpt_en register is used to enable or disable the corresponding endpoint (except endpoint 0) enable endpoint (bit=1) or disable endpoint (bit=0)    +     1 &
    &      *   1 ;      +     1 &
    &      *   1 ;  
 )     2 , 2 9     2 &  &   1 &  
ht82d22r/HT82D22A rev. 1.00 21 november 6, 2009 the bitmaps are list as follows : register name r/w register address bit7~bit3 reserved bit 2 bit 1 bit 0 default value pipe_ctrl r/w 01000001b  pipe 2 pipe 1 pipe 0 00000110 stall r/w 01000011b  pipe 2 pipe 1 pipe 0 00000110 pipe r 01000100b  pipe 2 pipe 1 pipe 0 00000000 endpt_en r/w 01000001b  pipe 2 pipe 1 pipe 0 00000111 pipe_ctrl (41h), stall (43h), pipe (44h) and endpt_en (47h) registers the sies register is used to indicate the present signal state which the sie receives and also defines whether the sie has to change the device address automatically. bit no. function read/write register address 7 mni r/w 01000001b 6~2  1 f0_err r/w 0 adr_set r/w sies (45h) register table function name read/ write description adr_set r/w this bit is used to configure the usb sie to automatically change the device address with the value of the address+remote_wakeup register (42h). when this bit is set to 1 by f/w, the usb sie will update the device address with the value of the address+remote_wakeup register (42h) after the pc host has successfully read the data from the device by the in operation. the usb sie will clear the bit after updating the device ad- dress. otherwise, when this bit is cleared to 0, the usb sie will update the device address im- mediately after an address is written to the address+remote_wakeup register (42h). f0_err r/w this bit is used to indicate when there are some errors that occurred when the fifo0 is ac- cessed. this bit is set by the usb sie and cleared by f/w.  bit 2~bit 6 reserved bit r/w this bit is used to control whether the usb interrupt is output to the mcu in nak respon. sies function table the misc register is actually a command + status to control the desired fifo action and to show the status of the de - sired fifo. every bit s meaning and usage are listed as follows: bit no. function read/write register address 7 len0 r/w 01000110b 6 ready r 5 scmd r/w 4 selp1 r/w 3 selp0 r/w 2 clear r/w 1 tx r/w 0 req r/w misc (46h) registers table
ht82d22r/HT82D22A rev. 1.00 22 november 6, 2009 misc register combines a command and status to control desired endpoint fifo action and to show the status of the desired endpoint fifo. the misc will be cleared by usb reset signal. bit no. label r/w function 0 req r/w after setting the other status of the desired one in the misc, endpoint fifo can be requested by setting this bit to 1 . after the job has been done, this bit has to be cleared to 0 . 1 tx r/w this bit defines the direction of data transferring between mcu and endpoint fifo. when the tx is set to 1 , this means that the mcu wants to write data to the end - point fifo. after the job has been done, this bit has to be cleared to 0 before termi - nating request to represent the end of transferring. for reading action, this bit has to be cleared to 0 to represent that mcu wants to read data from the endpoint fifo and has to be set to 1 after the job is done. 2 clear r/w clear the requested endpoint fifo, even if the endpoint fifo is not ready. 4 3 selp1 selp0 r/w defines which endpoint fifo is selected, selp1,selp0: 00: endpoint fifo0 01: endpoint fifo1 10: endpoint fifo2 11: reserved 5 scmd r/w used to show that the data in endpoint fifo is a setup command. this bit has to be cleared by firmware. that is to say, even the mcu is busy, the device will not miss any setup commands from the host. 6 ready r read only status bit, this bit is used to indicate that the desired endpoint fifo is ready to work. 7 len0 r/w used to indicate that a 0-sized packet is sent from a host to the mcu. this bit should be cleared by firmware. misc (46h) register the mcu can communicate with the endpoint fifo by setting the corresponding registers, of which address is listed in the following table. after reading the current data, next data will show after 2 s, used to check the endpoint fifo status and response to misc register, if read/write action is still going on. registers r/w bank address bit7~bit0 fifo0 r/w 1 48h data7~data0 fifo1 r/w 1 49h data7~data0 fifo2 r/w 1 4ah data7~data0 there are some timing constrains and usages illustrated here. by setting the misc register, mcu can perform reading, writing and clearing actions. there are some examples shown in the following table for endpoint fifo reading, writing and clearing. actions misc setting flow and status read fifo0 sequence 00h01h delay 2 s, check 41h read* from fifo0 register and check not ready (01h) 03h02h write fifo1 sequence 0ah0bh delay 2 s, check 4bh write* to fifo1 register and check not ready (0bh) 09h08h check whether fifo0 can be read or not 00h01h delay 2 s, check 41h (ready) or 01h (not ready)00h check whether fifo1 can be written or not 0ah0bh delay 2 s, check 4bh (ready) or 0bh (not ready)0ah read 0-sized packet sequence form fifo0 00h01h delay 2 s, check 81h read once (01h)03h02h write 0-sized packet sequence to fifo1 0ah0bh delay 2 s, check 0bh0fh0dh08h note: *: there are 2 s existing between 2 reading action or between 2 writing action
ht82d22r/HT82D22A rev. 1.00 23 november 6, 2009 the definitions of the usb/ps2 status and control register (usc; 1ah) are as shown. bit no. label r/w function 0 susp r read only, usb suspend indication. when this bit is set to 1 (set by sie ), it indi - cates the usb bus enters suspend mode. the usb interrupt is also triggered on any changes of this bit. 1 rmwk w usb remote wake up command. it is set by mcu to force the usb host leaving the suspend mode. when this bit is set to 1 ,2 s delay for clearing this bit to 0 is needed to insure the rmwk command is accepted by sie. 2 urst r/w usb reset indication. this bit is set/cleared by usb sie. this bit is used to detect which bus (ps2 or usb) is attached. when the urst is set to 1 , this indicates that a usb reset has occurred (the attached bus is usb) and a usb interrupt will be ini - tialized. 3 resume r usb resume indication. when the usb leaves the suspend mode, this bit is set to 1 (set by sie). this bit will appear 20ms waiting for the mcu to detect. when the resume is set by the sie, an interrupt will be generated to wake-up the mcu. in or - der to detect the suspend state, the mcu should set the usbcken and clear susp2 (in scc register) to enable the sie detecting function. the resume will be cleared while the susp is going 0 . when the mcu is detecting the susp, the re - sume (wakes-up the mcu ) should be remembered and taken into consideration. 4 ps2dai r read only, usbd-/data input 5 ps2cki r read only, usbd+/clk input 6 ps2dao w data for driving the usbd-/data pin when working under 3d ps2 mouse function. (default= 1 ) 7 ps2cko w data for driving the usbd+/clk pin when working under 3d ps2 mouse function. (default= 1 ) usc (1ah) register the usr (usb endpoint interrupt status register) register is used to indicate which endpoint is accessed and to select the serial bus (ps2 or usb). the endpoint request flags (ep0if, ep1if and ep2if) are used to indicate which end- points are accessed. if an endpoint is accessed, the related endpoint request flag will be set to 1 and the usb inter- rupt will occur (if the usb interrupt is enabled and the stack is not full). when the active endpoint request flag is served, the endpoint request flag has to be cleared to 0 . bit no. label r/w function 0 ep0if r/w when this bit is set to 1 (set by the sie), it indicates the endpoint 0 is accessed and a usb interrupt will occur. when the interrupt has been served, this bit should be cleared by firmware. 1 ep1if r/w when this bit is set to 1 (set by the sie), it indicates the endpoint 1 is accessed and a usb interrupt will occur. when the interrupt has been served, this bit should be cleared by firmware. 2 ep2if r/w when this bit is set to 1 (set by the sie), it indicates the endpoint 2 is accessed and a usb interrupt will occur. when the interrupt has been served, this bit should be cleared by firmware. 3, 6  reserved 4 sps2 r/w the ps2 function is selected when this bit is set to 1 . (default= 0 ) 5 susb r/w the usb function is selected when this bit is set to 1 . (default= 0 ) 7 usb _flag r/w this flag is used to show the mcu is in usb mode. (bit=1) this bit is r/w by fw and will be cleared to 0 after power-on reset. (default= 0 ) usr (1bh) register
ht82d22r/HT82D22A rev. 1.00 24 november 6, 2009 there is a system clock control register implemented to select the clock used in the mcu. this register consists of the usb clock control bit (usbcken), second suspend mode control bit (susp2) and system clock selection (sysclk). bit no. label r/w function 2~0, 7  undefined, should be cleared to 0 3 usbcken r/w usb clock control bit. when this bit is set to 1 , it indicates that the usb clock is en - abled. otherwise, the usb clock is turned-off. (default= 0 ) 4 susp2 r/w this bit is used to reduce power consumption in the suspend mode. in the normal mode this bit must be cleared to zero (default=0). in the halt mode this bit should be set high to reduce power consumption. if in usb mode set this bit lvr opt must disable 5 ps2_flag r/w this flag is used to show the mcu is under ps2 mode. (bit=1) this bit is r/w by fw and will be cleared to 0 after power-on reset. (default= 0 ) 6 sysclk r/w this bit is used to specify the system oscillator frequency used by the mcu. if a 6mhz crystal oscillator or resonator is used, this bit should be set to 1 . if a 12mhz crystal oscillator or resonator is used, this bit should be cleared to 0 (default). scc (1ch) register table high byte pointer for current table read tbhp (address 0x1f) register bits labels read/write option functions tbhp (0x1f) 3~0 pgc3~pgc0 r  store current table read bit11~bit8 data 27mhz fsk receiver function there is two channel integrated rf transceiver designed for human interface devices (hid). operating at 27mhz, it provide frequency selection from 8 discrete channels via a parallel control pb1~pb3 or pc3, pd4, pd5, the frequency range is 26.945~26.995mhz and channel spacing is 50khz. it provide power down to reduce power consumption by 27mhz fsk receiver power down bit pd6/pb7 for fsk-a/fsk-b. the optimized receiver design enables reception up to 3khz per channel. it supply demodulation output data with pc0/pb0 for fsk-a/ fsk-b. register bits labels read/write option functions pd6 0 pd6 r/w  27mhz fsk-a receiver power down bit when 1 indicate fsk-a receiver for power down mode, otherwise for normal mode default value 0 pc3 pd4 pd5 3 4 5 pc3 pd4 pd5 r/w  parallel control bit 2~bit 0 communication spacing control 000: 26.995 mhz 001: 27.045 mhz 010: 27.095 mhz 011: 27.145 mhz 100: 27.195 mhz 101: 27.245 mhz 110: 27.295 mhz 111: 26.945 mhz note: 27mhz fsk-a receiver control register pcc.6, pcc.3, pdc.4, pdc.5 must for be 0 , the other bits are re - served for pcc (except pcc.0 for fsk-a data output ) and pdc. 27mhz fsk-a control register
ht82d22r/HT82D22A rev. 1.00 25 november 6, 2009 register bits labels read/write option functions pb 7 pb7 r/w  27mhz fsk-b receiver power down bit when 1 indicate fsk-b receiver for power down mode, otherwise for normal mode. default value 0 1~3 pb1~pb3 r/w  parallel control bit 2~bit 0 communication spacing control 000: 26.995 mhz 001: 27.045 mhz 010: 27.095 mhz 011: 27.145 mhz 100: 27.195 mhz 101: 27.245 mhz 110: 27.295 mhz 111: 26.945 mhz 4~6 pb4~pb6  reserved bit. note: 27mhz fsk receiver control register pb1~pb3 and pb7 must be 0 pb4~pb6 are reserved. 27mhz fsk-b control register configuration options the following table shows all kinds of option in the microcontroller. all of the options must be defined to ensure proper system functioning. no. option 1 chip lock bit (by bit) 2 pa0~pa7 pull-high resistor enabled or disabled (by bit) 3 pb0 pull-high resistor enabled or disabled 4 pc0 pull-high resistor enabled or disabled 5 lvr enable or disable 6 wdt enable or disable 7 wdt clock source: f sys /4 or wdtosc 8 clrwdt instruction(s): 1 or 2 9 pa0~pa7 output structures: cmos/nmos (open-drain)/pmos (open-source) 10 pa0~pa7 wake-up enabled or disabled (by bit) 11 pb0 wake-up enabled or disabled 12 pc0 wake-up enabled or disabled 14 tbhp enable or disable (default disable)
application circuits crystal for multiple i/o applications note: the resistance and capacitance for the reset circuit should be designed in such a way as to ensure that the vdd is stable and remains within a valid operating voltage range before bringing res to high. components with * are used for emc issue. ht82d22r/HT82D22A rev. 1.00 26 november 6, 2009
ht82d22r/HT82D22A rev. 1.00 27 november 6, 2009 instruction set introduction central to the successful operation of any microcontroller is its instruction set, which is a set of pro - gram instruction codes that directs the microcontroller to perform certain operations. in the case of holtek microcontrollers, a comprehensive and flexible set of over 60 instructions is provided to enable programmers to implement their application with the minimum of pro - gramming overheads. for easier understanding of the various instruction codes, they have been subdivided into several func - tional groupings. instruction timing most instructions are implemented within one instruc - tion cycle. the exceptions to this are branch, call, or ta - ble read instructions where two instruction cycles are required. one instruction cycle is equal to 4 system clock cycles, therefore in the case of an 8mhz system oscillator, most instructions would be implemented within 0.5 s and branch or call instructions would be im - plemented within 1 s. although instructions which re - quire one more cycle to implement are generally limited to the jmp, call, ret, reti and table read instruc- tions, it is important to realize that any other instructions which involve manipulation of the program counter low register or pcl will also take one more cycle to imple- ment. as instructions which change the contents of the pcl will imply a direct jump to that new address, one more cycle will be required. examples of such instruc- tions would be clr pcl or mov pcl, a . for the case of skip instructions, it must be noted that if the re- sult of the comparison involves a skip operation then this will also take one more cycle, if no skip is involved then only one cycle is required. moving and transferring data the transfer of data within the microcontroller program is one of the most frequently used operations. making use of three kinds of mov instructions, data can be transferred from registers to the accumulator and vice-versa as well as being able to move specific imme - diate data directly into the accumulator. one of the most important data transfer applications is to receive data from the input ports and transfer data to the output ports. arithmetic operations the ability to perform certain arithmetic operations and data manipulation is a necessary feature of most microcontroller applications. within the holtek microcontroller instruction set are a range of add and subtract instruction mnemonics to enable the necessary arithmetic to be carried out. care must be taken to en - sure correct handling of carry and borrow data when re - sults exceed 255 for addition and less than 0 for subtraction. the increment and decrement instructions inc, inca, dec and deca provide a simple means of increasing or decreasing by a value of one of the values in the destination specified. logical and rotate operations the standard logical operations such as and, or, xor and cpl all have their own instruction within the holtek microcontroller instruction set. as with the case of most instructions involving data manipulation, data must pass through the accumulator which may involve additional programming steps. in all logical data operations, the zero flag may be set if the result of the operation is zero. another form of logical data manipulation comes from the rotate instructions such as rr, rl, rrc and rlc which provide a simple means of rotating one bit right or left. different rotate instructions exist depending on pro - gram requirements. rotate instructions are useful for serial port programming applications where data can be rotated from an internal register into the carry bit from where it can be examined and the necessary serial bit set high or low. another application where rotate data operations are used is to implement multiplication and division calculations. branches and control transfer program branching takes the form of either jumps to specified locations using the jmp instruction or to a sub- routine using the call instruction. they differ in the sense that in the case of a subroutine call, the program must return to the instruction immediately when the sub - routine has been carried out. this is done by placing a return instruction ret in the subroutine which will cause the program to jump back to the address right after the call instruction. in the case of a jmp instruction, the program simply jumps to the desired location. there is no requirement to jump back to the original jumping off point as in the case of the call instruction. one special and extremely useful set of branch instructions are the conditional branches. here a decision is first made re - garding the condition of a certain data memory or indi - vidual bits. depending upon the conditions, the program will continue with the next instruction or skip over it and jump to the following instruction. these instructions are the key to decision making and branching within the pro - gram perhaps determined by the condition of certain in - put switches or by the condition of internal data bits.
ht82d22r/HT82D22A rev. 1.00 28 november 6, 2009 bit operations the ability to provide single bit operations on data mem - ory is an extremely flexible feature of all holtek microcontrollers. this feature is especially useful for output port bit programming where individual bits or port pins can be directly set high or low using either the set [m].i or clr [m].i instructions respectively. the fea - ture removes the need for programmers to first read the 8-bit output port, manipulate the input data to ensure that other bits are not changed and then output the port with the correct new data. this read-modify-write pro - cess is taken care of automatically when these bit oper - ation instructions are used. table read operations data storage is normally implemented by using regis - ters. however, when working with large amounts of fixed data, the volume involved often makes it inconve - nient to store the fixed data in the data memory. to over - come this problem, holtek microcontrollers allow an area of program memory to be setup as a table where data can be directly stored. a set of easy to use instruc - tions provides the means by which this fixed data can be referenced and retrieved from the program memory. other operations in addition to the above functional instructions, a range of other instructions also exist such as the halt in - struction for power-down operations and instructions to control the operation of the watchdog timer for reliable program operations under extreme electric or electro - magnetic environments. for their relevant operations, refer to the functional related sections. instruction set summary the following table depicts a summary of the instruction set categorised according to function and can be con - sulted as a basic instruction reference using the follow - ing listed conventions. table conventions: x: bits immediate data m: data memory address a: accumulator i: 0~7 number of bits addr: program memory address mnemonic description cycles flag affected arithmetic add a,[m] addm a,[m] add a,x adc a,[m] adcm a,[m] sub a,x sub a,[m] subm a,[m] sbc a,[m] sbcm a,[m] daa [m] add data memory to acc add acc to data memory add immediate data to acc add data memory to acc with carry add acc to data memory with carry subtract immediate data from the acc subtract data memory from acc subtract data memory from acc with result in data memory subtract data memory from acc with carry subtract data memory from acc with carry, result in data memory decimal adjust acc for addition with result in data memory 1 1 note 1 1 1 note 1 1 1 note 1 1 note 1 note z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov c logic operation and a,[m] or a,[m] xor a,[m] andm a,[m] orm a,[m] xorm a,[m] and a,x or a,x xor a,x cpl [m] cpla [m] logical and data memory to acc logical or data memory to acc logical xor data memory to acc logical and acc to data memory logical or acc to data memory logical xor acc to data memory logical and immediate data to acc logical or immediate data to acc logical xor immediate data to acc complement data memory complement data memory with result in acc 1 1 1 1 note 1 note 1 note 1 1 1 1 note 1 z z z z z z z z z z z increment & decrement inca [m] inc [m] deca [m] dec [m] increment data memory with result in acc increment data memory decrement data memory with result in acc decrement data memory 1 1 note 1 1 note z z z z
ht82d22r/HT82D22A rev. 1.00 29 november 6, 2009 mnemonic description cycles flag affected rotate rra [m] rr [m] rrca [m] rrc [m] rla [m] rl [m] rlca [m] rlc [m] rotate data memory right with result in acc rotate data memory right rotate data memory right through carry with result in acc rotate data memory right through carry rotate data memory left with result in acc rotate data memory left rotate data memory left through carry with result in acc rotate data memory left through carry 1 1 note 1 1 note 1 1 note 1 1 note none none c c none none c c data move mov a,[m] mov [m],a mov a,x move data memory to acc move acc to data memory move immediate data to acc 1 1 note 1 none none none bit operation clr [m].i set [m].i clear bit of data memory set bit of data memory 1 note 1 note none none branch jmp addr sz [m] sza [m] sz [m].i snz [m].i siz [m] sdz [m] siza [m] sdza [m] call addr ret ret a,x reti jump unconditionally skip if data memory is zero skip if data memory is zero with data movement to acc skip if bit i of data memory is zero skip if bit i of data memory is not zero skip if increment data memory is zero skip if decrement data memory is zero skip if increment data memory is zero with result in acc skip if decrement data memory is zero with result in acc subroutine call return from subroutine return from subroutine and load immediate data to acc return from interrupt 2 1 note 1 note 1 note 1 note 1 note 1 note 1 note 1 note 2 2 2 2 none none none none none none none none none none none none none table read tabrdc [m] tabrdl [m] read table (current page) to tblh and data memory read table (last page) to tblh and data memory 2 note 2 note none none miscellaneous nop clr [m] set [m] clr wdt clr wdt1 clr wdt2 swap [m] swapa [m] halt no operation clear data memory set data memory clear watchdog timer pre-clear watchdog timer pre-clear watchdog timer swap nibbles of data memory swap nibbles of data memory with result in acc enter power down mode 1 1 note 1 note 1 1 1 1 note 1 1 none none none to, pdf to, pdf to, pdf none none to, pdf note: 1. for skip instructions, if the result of the comparison involves a skip then two cycles are required, if no skip takes place only one cycle is required. 2. any instruction which changes the contents of the pcl will also require 2 cycles for execution. 3. for the clr wdt1 and clr wdt2 instructions the to and pdf flags may be affected by the execution status. the to and pdf flags are cleared after both clr wdt1 and clr wdt2 instructions are consecutively executed. otherwise the to and pdf flags remain unchanged.
instruction definition adc a,[m] add data memory to acc with carry description the contents of the specified data memory, accumulator and the carry flag are added. the result is stored in the accumulator. operation acc  acc+[m]+c affected flag(s) ov, z, ac, c adcm a,[m] add acc to data memory with carry description the contents of the specified data memory, accumulator and the carry flag are added. the result is stored in the specified data memory. operation [m]  acc+[m]+c affected flag(s) ov, z, ac, c add a,[m] add data memory to acc description the contents of the specified data memory and the accumulator are added. the result is stored in the accumulator. operation acc  acc + [m] affected flag(s) ov, z, ac, c add a,x add immediate data to acc description the contents of the accumulator and the specified immediate data are added. the result is stored in the accumulator. operation acc  acc+x affected flag(s) ov, z, ac, c addm a,[m] add acc to data memory description the contents of the specified data memory and the accumulator are added. the result is stored in the specified data memory. operation [m]  acc + [m] affected flag(s) ov, z, ac, c and a,[m] logical and data memory to acc description data in the accumulator and the specified data memory perform a bitwise logical and op - eration. the result is stored in the accumulator. operation acc  acc and [m] affected flag(s) z and a,x logical and immediate data to acc description data in the accumulator and the specified immediate data perform a bitwise logical and operation. the result is stored in the accumulator. operation acc  acc and x affected flag(s) z andm a,[m] logical and acc to data memory description data in the specified data memory and the accumulator perform a bitwise logical and op - eration. the result is stored in the data memory. operation [m]  acc and [m] affected flag(s) z ht82d22r/HT82D22A rev. 1.00 30 november 6, 2009
call addr subroutine call description unconditionally calls a subroutine at the specified address. the program counter then in - crements by 1 to obtain the address of the next instruction which is then pushed onto the stack. the specified address is then loaded and the program continues execution from this new address. as this instruction requires an additional operation, it is a two cycle instruc - tion. operation stack  program counter + 1 program counter  addr affected flag(s) none clr [m] clear data memory description each bit of the specified data memory is cleared to 0. operation [m]  00h affected flag(s) none clr [m].i clear bit of data memory description bit i of the specified data memory is cleared to 0. operation [m].i  0 affected flag(s) none clr wdt clear watchdog timer description the to, pdf flags and the wdt are all cleared. operation wdt cleared to  0 pdf  0 affected flag(s) to, pdf clr wdt1 pre-clear watchdog timer description the to, pdf flags and the wdt are all cleared. note that this instruction works in conjunc- tion with clr wdt2 and must be executed alternately with clr wdt2 to have effect. re- petitively executing this instruction without alternately executing clr wdt2 will have no effect. operation wdt cleared to  0 pdf  0 affected flag(s) to, pdf clr wdt2 pre-clear watchdog timer description the to, pdf flags and the wdt are all cleared. note that this instruction works in conjunc - tion with clr wdt1 and must be executed alternately with clr wdt1 to have effect. re - petitively executing this instruction without alternately executing clr wdt1 will have no effect. operation wdt cleared to  0 pdf  0 affected flag(s) to, pdf ht82d22r/HT82D22A rev. 1.00 31 november 6, 2009
cpl [m] complement data memory description each bit of the specified data memory is logically complemented (1 s complement). bits which previously contained a 1 are changed to 0 and vice versa. operation [m]  [m] affected flag(s) z cpla [m] complement data memory with result in acc description each bit of the specified data memory is logically complemented (1 s complement). bits which previously contained a 1 are changed to 0 and vice versa. the complemented result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc  [m] affected flag(s) z daa [m] decimal-adjust acc for addition with result in data memory description convert the contents of the accumulator value to a bcd ( binary coded decimal) value re - sulting from the previous addition of two bcd variables. if the low nibble is greater than 9 or if ac flag is set, then a value of 6 will be added to the low nibble. otherwise the low nibble remains unchanged. if the high nibble is greater than 9 or if the c flag is set, then a value of 6 will be added to the high nibble. essentially, the decimal conversion is performed by add - ing 00h, 06h, 60h or 66h depending on the accumulator and flag conditions. only the c flag may be affected by this instruction which indicates that if the original bcd sum is greater than 100, it allows multiple precision decimal addition. operation [m]  acc + 00h or [m]  acc + 06h or [m]  acc + 60h or [m]  acc + 66h affected flag(s) c dec [m] decrement data memory description data in the specified data memory is decremented by 1. operation [m]  [m]  1 affected flag(s) z deca [m] decrement data memory with result in acc description data in the specified data memory is decremented by 1. the result is stored in the accu - mulator. the contents of the data memory remain unchanged. operation acc  [m]  1 affected flag(s) z halt enter power down mode description this instruction stops the program execution and turns off the system clock. the contents of the data memory and registers are retained. the wdt and prescaler are cleared. the power down flag pdf is set and the wdt time-out flag to is cleared. operation to  0 pdf  1 affected flag(s) to, pdf ht82d22r/HT82D22A rev. 1.00 32 november 6, 2009
inc [m] increment data memory description data in the specified data memory is incremented by 1. operation [m]  [m]+1 affected flag(s) z inca [m] increment data memory with result in acc description data in the specified data memory is incremented by 1. the result is stored in the accumu - lator. the contents of the data memory remain unchanged. operation acc  [m]+1 affected flag(s) z jmp addr jump unconditionally description the contents of the program counter are replaced with the specified address. program execution then continues from this new address. as this requires the insertion of a dummy instruction while the new address is loaded, it is a two cycle instruction. operation program counter  addr affected flag(s) none mov a,[m] move data memory to acc description the contents of the specified data memory are copied to the accumulator. operation acc  [m] affected flag(s) none mov a,x move immediate data to acc description the immediate data specified is loaded into the accumulator. operation acc  x affected flag(s) none mov [m],a move acc to data memory description the contents of the accumulator are copied to the specified data memory. operation [m]  acc affected flag(s) none nop no operation description no operation is performed. execution continues with the next instruction. operation no operation affected flag(s) none or a,[m] logical or data memory to acc description data in the accumulator and the specified data memory perform a bitwise logical or oper - ation. the result is stored in the accumulator. operation acc  acc or [m] affected flag(s) z ht82d22r/HT82D22A rev. 1.00 33 november 6, 2009
or a,x logical or immediate data to acc description data in the accumulator and the specified immediate data perform a bitwise logical or op - eration. the result is stored in the accumulator. operation acc  acc or x affected flag(s) z orm a,[m] logical or acc to data memory description data in the specified data memory and the accumulator perform a bitwise logical or oper - ation. the result is stored in the data memory. operation [m]  acc or [m] affected flag(s) z ret return from subroutine description the program counter is restored from the stack. program execution continues at the re - stored address. operation program counter  stack affected flag(s) none ret a,x return from subroutine and load immediate data to acc description the program counter is restored from the stack and the accumulator loaded with the specified immediate data. program execution continues at the restored address. operation program counter  stack acc  x affected flag(s) none reti return from interrupt description the program counter is restored from the stack and the interrupts are re-enabled by set- ting the emi bit. emi is the master interrupt global enable bit. if an interrupt was pending when the reti instruction is executed, the pending interrupt routine will be processed be- fore returning to the main program. operation program counter  stack emi  1 affected flag(s) none rl [m] rotate data memory left description the contents of the specified data memory are rotated left by 1 bit with bit 7 rotated into bit 0. operation [m].(i+1)  [m].i; (i = 0~6) [m].0  [m].7 affected flag(s) none rla [m] rotate data memory left with result in acc description the contents of the specified data memory are rotated left by 1 bit with bit 7 rotated into bit 0. the rotated result is stored in the accumulator and the contents of the data memory re - main unchanged. operation acc.(i+1)  [m].i; (i = 0~6) acc.0  [m].7 affected flag(s) none ht82d22r/HT82D22A rev. 1.00 34 november 6, 2009
rlc [m] rotate data memory left through carry description the contents of the specified data memory and the carry flag are rotated left by 1 bit. bit 7 replaces the carry bit and the original carry flag is rotated into bit 0. operation [m].(i+1)  [m].i; (i = 0~6) [m].0  c c  [m].7 affected flag(s) c rlca [m] rotate data memory left through carry with result in acc description data in the specified data memory and the carry flag are rotated left by 1 bit. bit 7 replaces the carry bit and the original carry flag is rotated into the bit 0. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc.(i+1)  [m].i; (i = 0~6) acc.0  c c  [m].7 affected flag(s) c rr [m] rotate data memory right description the contents of the specified data memory are rotated right by 1 bit with bit 0 rotated into bit 7. operation [m].i  [m].(i+1); (i = 0~6) [m].7  [m].0 affected flag(s) none rra [m] rotate data memory right with result in acc description data in the specified data memory and the carry flag are rotated right by 1 bit with bit 0 ro- tated into bit 7. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc.i  [m].(i+1); (i = 0~6) acc.7  [m].0 affected flag(s) none rrc [m] rotate data memory right through carry description the contents of the specified data memory and the carry flag are rotated right by 1 bit. bit 0 replaces the carry bit and the original carry flag is rotated into bit 7. operation [m].i  [m].(i+1); (i = 0~6) [m].7  c c  [m].0 affected flag(s) c rrca [m] rotate data memory right through carry with result in acc description data in the specified data memory and the carry flag are rotated right by 1 bit. bit 0 re - places the carry bit and the original carry flag is rotated into bit 7. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc.i  [m].(i+1); (i = 0~6) acc.7  c c  [m].0 affected flag(s) c ht82d22r/HT82D22A rev. 1.00 35 november 6, 2009
sbc a,[m] subtract data memory from acc with carry description the contents of the specified data memory and the complement of the carry flag are sub - tracted from the accumulator. the result is stored in the accumulator. note that if the result of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation acc  acc  [m]  c affected flag(s) ov, z, ac, c sbcm a,[m] subtract data memory from acc with carry and result in data memory description the contents of the specified data memory and the complement of the carry flag are sub - tracted from the accumulator. the result is stored in the data memory. note that if the re - sult of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation [m]  acc  [m]  c affected flag(s) ov, z, ac, c sdz [m] skip if decrement data memory is 0 description the contents of the specified data memory are first decremented by 1. if the result is 0 the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation [m]  [m]  1 skip if [m] = 0 affected flag(s) none sdza [m] skip if decrement data memory is zero with result in acc description the contents of the specified data memory are first decremented by 1. if the result is 0, the following instruction is skipped. the result is stored in the accumulator but the specified data memory contents remain unchanged. as this requires the insertion of a dummy in- struction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0, the program proceeds with the following instruction. operation acc  [m]  1 skip if acc = 0 affected flag(s) none set [m] set data memory description each bit of the specified data memory is set to 1. operation [m]  ffh affected flag(s) none set [m].i set bit of data memory description bit i of the specified data memory is set to 1. operation [m].i  1 affected flag(s) none ht82d22r/HT82D22A rev. 1.00 36 november 6, 2009
siz [m] skip if increment data memory is 0 description the contents of the specified data memory are first incremented by 1. if the result is 0, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation [m]  [m]+1 skip if [m] = 0 affected flag(s) none siza [m] skip if increment data memory is zero with result in acc description the contents of the specified data memory are first incremented by 1. if the result is 0, the following instruction is skipped. the result is stored in the accumulator but the specified data memory contents remain unchanged. as this requires the insertion of a dummy in - struction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation acc  [m]+1 skip if acc = 0 affected flag(s) none snz [m].i skip if bit i of data memory is not 0 description if bit i of the specified data memory is not 0, the following instruction is skipped. as this re - quires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is 0 the program proceeds with the following instruction. operation skip if [m].i  0 affected flag(s) none sub a,[m] subtract data memory from acc description the specified data memory is subtracted from the contents of the accumulator. the result is stored in the accumulator. note that if the result of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation acc  acc  [m] affected flag(s) ov, z, ac, c subm a,[m] subtract data memory from acc with result in data memory description the specified data memory is subtracted from the contents of the accumulator. the result is stored in the data memory. note that if the result of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation [m]  acc  [m] affected flag(s) ov, z, ac, c sub a,x subtract immediate data from acc description the immediate data specified by the code is subtracted from the contents of the accumu - lator. the result is stored in the accumulator. note that if the result of subtraction is nega - tive, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation acc  acc  x affected flag(s) ov, z, ac, c ht82d22r/HT82D22A rev. 1.00 37 november 6, 2009
swap [m] swap nibbles of data memory description the low-order and high-order nibbles of the specified data memory are interchanged. operation [m].3~[m].0  [m].7 ~ [m].4 affected flag(s) none swapa [m] swap nibbles of data memory with result in acc description the low-order and high-order nibbles of the specified data memory are interchanged. the result is stored in the accumulator. the contents of the data memory remain unchanged. operation acc.3 ~ acc.0  [m].7 ~ [m].4 acc.7 ~ acc.4  [m].3 ~ [m].0 affected flag(s) none sz [m] skip if data memory is 0 description if the contents of the specified data memory is 0, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruc - tion. operation skip if [m] = 0 affected flag(s) none sza [m] skip if data memory is 0 with data movement to acc description the contents of the specified data memory are copied to the accumulator. if the value is zero, the following instruction is skipped. as this requires the insertion of a dummy instruc - tion while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation acc  [m] skip if [m] = 0 affected flag(s) none sz [m].i skip if bit i of data memory is 0 description if bit i of the specified data memory is 0, the following instruction is skipped. as this re- quires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0, the program proceeds with the following instruction. operation skip if [m].i = 0 affected flag(s) none tabrdc [m] read table (current page) to tblh and data memory description the low byte of the program code (current page) addressed by the table pointer (tblp) is moved to the specified data memory and the high byte moved to tblh. operation [m]  program code (low byte) tblh  program code (high byte) affected flag(s) none tabrdl [m] read table (last page) to tblh and data memory description the low byte of the program code (last page) addressed by the table pointer (tblp) is moved to the specified data memory and the high byte moved to tblh. operation [m]  program code (low byte) tblh  program code (high byte) affected flag(s) none ht82d22r/HT82D22A rev. 1.00 38 november 6, 2009
xor a,[m] logical xor data memory to acc description data in the accumulator and the specified data memory perform a bitwise logical xor op - eration. the result is stored in the accumulator. operation acc  acc xor [m] affected flag(s) z xorm a,[m] logical xor acc to data memory description data in the specified data memory and the accumulator perform a bitwise logical xor op - eration. the result is stored in the data memory. operation [m]  acc xor [m] affected flag(s) z xor a,x logical xor immediate data to acc description data in the accumulator and the specified immediate data perform a bitwise logical xor operation. the result is stored in the accumulator. operation acc  acc xor x affected flag(s) z ht82d22r/HT82D22A rev. 1.00 39 november 6, 2009
package information saw type 48-pin (7mm 7mm) qfn outline dimensions symbol dimensions in inch min. nom. max. a 0.028  0.031 a1 0.000  0.002 a3  0.008  b 0.007  0.012 d  0.276  e  0.276  e  0.020  d2 0.177  0.227 e2 0.177  0.227 l 0.012  0.020 k 0.008  symbol dimensions in mm min. nom. max. a 0.70  0.80 a1 0.00  0.05 a3  0.203  b 0.18  0.30 d  7.00  e  7.00  e  0.50  d2 4.50  5.76 e2 4.50  5.76 l 0.30  0.50 k 0.20  ht82d22r/HT82D22A rev. 1.00 40 november 6, 2009  +  b    7   , + ,    ,  7 , ( , 9 7 : 7 - ( <
ht82d22r/HT82D22A rev. 1.00 41 november 6, 2009 copyright  2009 by holtek semiconductor inc. the information appearing in this data sheet is believed to be accurate at the time of publication. however, holtek as - sumes no responsibility arising from the use of the specifications described. the applications mentioned herein are used solely for the purpose of illustration and holtek makes no warranty or representation that such applications will be suitable without further modification, nor recommends the use of its products for application that may present a risk to human life due to malfunction or otherwise. holtek s products are not authorized for use as critical components in life support devices or systems. holtek reserves the right to alter its products without prior notification. for the most up-to-date information, please visit our web site at http://www.holtek.com.tw. holtek semiconductor inc. (headquarters) no.3, creation rd. ii, science park, hsinchu, taiwan tel: 886-3-563-1999 fax: 886-3-563-1189 http://www.holtek.com.tw holtek semiconductor inc. (taipei sales office) 4f-2, no. 3-2, yuanqu st., nankang software park, taipei 115, taiwan tel: 886-2-2655-7070 fax: 886-2-2655-7373 fax: 886-2-2655-7383 (international sales hotline) holtek semiconductor inc. (shenzhen sales office) 5f, unit a, productivity building, no.5 gaoxin m 2nd road, nanshan district, shenzhen, china 518057 tel: 86-755-8616-9908, 86-755-8616-9308 fax: 86-755-8616-9722 holtek semiconductor (usa), inc. (north america sales office) 46729 fremont blvd., fremont, ca 94538 tel: 1-510-252-9880 fax: 1-510-252-9885 http://www.holtek.com


▲Up To Search▲   

 
Price & Availability of HT82D22A

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X